package com.jianduyuan.anhuixiaoneng;

import android.os.Bundle;

import com.jianduyuan.anhuixiaoneng.channel.FlutterMethodChannel;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugins.GeneratedPluginRegistrant;

public class MainActivity extends FlutterActivity {

    @Override
    public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
        GeneratedPluginRegistrant.registerWith(flutterEngine);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        FlutterMethodChannel.getInstance().registerWith(this, getFlutterEngine().getDartExecutor().getBinaryMessenger());

        MethodChannel methodChannel = new MethodChannel(getFlutterEngine().getDartExecutor().getBinaryMessenger(), "flutter_method_channel");
//        methodChannel.setMethodCallHandler(new MethodChannel.MethodCallHandler() {
//            @Override
//            public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
//                String methodName = call.method;
//                if (methodName.equals("getCacheData")) {
//                    Toast.makeText(MainActivity.this, "getCacheData", Toast.LENGTH_LONG).show();
//                    Map<String, String> map = new HashMap<>();
//
//                    map.put("code", FlutterChannelConstant.METHOD_CHANNEL_CODE);
//                    map.put("message", "获取缓存大小");
//                    map.put("content", "100");
//                    result.success(new Gson().toJson(map));
//                }
//            }
//        });

    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onRestart() {
        super.onRestart();
    }
}
